mui.init({
	beforeback: function(){
		return true;
	}
});

mui.plusReady(function() {
	var phone_card = CmwMcore.$('phonecard');
	MeventMgr.onTouchstart(phone_card,function(event,self){
		$(".phone").show();
		$(".email").hide();
	});
	
	var email_card = CmwMcore.$('emailcard');
	MeventMgr.onTouchstart(email_card,function(event,self){
		$(".phone").hide();
		$(".email").show();
	});
	
	/*------ 提交手机验证码  ------*/
	var btn_phone = CmwMcore.$('btn_phone');
	MeventMgr.onTouchstart(btn_phone,function(event,self){
		var userId = plus.webview.currentWebview().userId;
		var url =UrlConfig.checkPoneCard;
		var phone=$("#phonecode").val();
	   	if(!phone){
	   		mui.alert("手机验证码不能为空！");
	   		return;
		}
		var pars = {phone:phone,smstype:'validPassword',guid:userId};
		MuiEventMgr.ajax(url,{pars:pars,
		  	sfn : function(data){
		  		var status = data.status;
		  		if(status=="true"){
					MuiEventMgr.open('resetPassword.html',{});
				}else if(status=="errorCard"){
					mui.alert("身份证号码错误！");
				}else if(status=="error"){
					mui.alert("手机验证码错误！");
				}else if(status=="overTime"){
					mui.alert("手机验证码失效！");
				}else{
					mui.alert("验证失败！");
				}	        		
		  	},ffn : function(){
		  		mui.alert("获取数据失败：["+err+"]");
		  	}
		});
	});
	
	/*------ 提交邮箱验证码  ------*/
	var btn_email = CmwMcore.$('btn_email');
	MeventMgr.onTouchstart(btn_email,function(event,self){
		var url =UrlConfig.checkEmailCord;
		var emailcode =$("#emailcode").val();
		if(!emailcode){
	   		mui.alert("邮箱验证码不能为空！");
	   		return;
		}
		var pars = {emailcode:emailcode};
		MuiEventMgr.ajax(url,{pars:pars,
		  	sfn : function(data){
		  		var status = data.status;
		  		if(status=="true"){
					MuiEventMgr.open('resetPassword.html',{});								
				}else if(status=="errorEmail"){
					mui.alert("邮件验证码错误！");									
				}else{
					mui.alert("验证失败！");									
				}	        		
		  	},ffn : function(){
		  		mui.alert("获取数据失败：["+err+"]");
		  	}
		});
	});
	
	
});